package com.bdqn.t330.ch11.service;

import com.bdqn.t330.ch11.dao.SysUserMapper;
import com.bdqn.t330.ch11.entity.SysUser;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("userService")
public class UserServiceImp implements UserService {

    @Resource
    SysUserMapper sysUserMapper;

    @Override
    public SysUser loginBiz(SysUser sysUser) {
        return sysUserMapper.login(sysUser);
    }

    @Override
    public List<SysUser> getUserList() {
        return sysUserMapper.getUserList();
    }

    @Override
    public List<SysUser> getUserListPageBiz(Integer pageIndex, Integer pageSize, String userName) {
        //计算出分页要显示的起始下标
        pageIndex = (pageIndex - 1) * pageSize;
        return sysUserMapper.getUserListPage(pageIndex, pageSize, userName);
    }

    @Override
    public Integer getUserListPageCount(String userName) {
        return sysUserMapper.getUserListPageCount(userName);
    }

    @Override
    public int add(SysUser sysUser) {
        return sysUserMapper.add(sysUser);
    }

    @Override
    public Integer deleteByIdBiz(Integer id) {
        return sysUserMapper.deleteById(id);
    }
}
